set(src_SRCS 
  XrdDMLog.cpp
  XrdDownloadManager.cpp
  XrdDMSimSiteInfo.cpp
  XrdDMSimFileInfo.cpp
  XrdDMSimFileCatalog.cpp
  XrdDMSimulator.cpp
)

set(src_SRCS_new
  XrdDownloadManagerLog.cpp
  XrdDownloadManagerAppMon.cpp
  XrdDownloadManagerBase.cpp
  XrdDownloadManagerAliEn.cpp
)

if(APPMON_FOUND)
  set(src_SRCS ${src_SRCS} XrdDownloadManagerAppMon.cpp)
else(APPMON_FOUND)
  set(APPMON_INCLUDE_DIR "")
  set(APPMON_LIBRARIES "")
  set(APPMON_LIB "")
endif(APPMON_FOUND)

set(INCLUDE_DIRECTORIES
  ${CMAKE_SOURCE_DIR}/src
  ${ALIEN_INCLUDE_DIR}
  ${APPMON_INCLUDE_DIR}
)
include_directories( ${INCLUDE_DIRECTORIES})

set(LINK_DIRECTORIES
  ${CMAKE_SOURCE_DIR}/src
  ${ALIEN_LIBRARIES}
  ${APPMON_LIBRARIES}
) 
link_directories( ${LINK_DIRECTORIES})

String(REPLACE ".cpp" ".hh" HDRS "${src_SRCS}")

# add_library(XrdDownloadManager ${src_SRCS} ${HDRS})
# target_link_libraries(XrdDownloadManager ${ALIEN_LIB} ${APPMON_LIB})

# add_executable(xrd-dm xrd-dm.cpp ${src_SRCS})
# target_link_libraries(xrd-dm ${ALIEN_LIB} ${APPMON_LIB})

add_executable(xrddm xrddm.cpp ${src_SRCS_new})
target_link_libraries(xrddm ${ALIEN_LIB} ${APPMON_LIB})


# target_link_libraries(xrd-dm XrdDownloadManager)

# add_executable(xrd-dm-sim xrd-dm-sim.cpp )
# target_link_libraries(xrd-dm-sim XrdDownloadManager)

# if(APPMON_FOUND)
#   add_executable(xrd-dm-appmon xrd-dm-appmon.cpp )
#   target_link_libraries(xrd-dm-appmon XrdDownloadManager ${APPMON_LIB})
# endif(APPMON_FOUND)
# XrdDownloadManager 
set(INS_TARTGETS xrddm)
# set(INS_TARTGETS ${INS_TARTGETS} xrd-dm-sim)
# if(APPMON_FOUND)
#   set(INS_TARTGETS ${INS_TARTGETS} xrd-dm-appmon)
# endif(APPMON_FOUND)

install(TARGETS ${INS_TARTGETS}
RUNTIME DESTINATION bin COMPONENT RUNTIME
LIBRARY DESTINATION lib COMPONENT RUNTIME
ARCHIVE DESTINATION lib/xrootd-dm COMPONENT DEVELOPMENT)
